package com.fxd.consumer;

import com.fxd.enums.RedisStreamEnum;
import com.fxd.model.Fruit;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.stream.ObjectRecord;
import org.springframework.data.redis.stream.StreamListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class FruitsGroupConsumer2 implements StreamListener<String, ObjectRecord<String, Fruit>> {

    @SneakyThrows
    @Override
    public void onMessage(ObjectRecord<String, Fruit> message) {
        log.info("group: {},consumer: {}接收到producer: {}消息id: {}", RedisStreamEnum.FRUITS_CONSUMER_GROUP.getValue()
                , RedisStreamEnum.FRUITS_GROUP_CONSUMER2.getValue(), RedisStreamEnum.FRUITS_PRODUCER_STREAM.getValue()
                , message.getId());
        log.info("id: {}", message.getId());
        log.info("stream: {}", message.getStream());
        log.info("value: {}", message.getValue());
    }

}
